import render_content from "./render_content.mjs";

export default function (container, template) {
  append(container, render_content(container, template));
}

function append(container, content) {
  if (typeof content === "string") {
    let wrapper = document.createElement(container.nodeName);
    let fr = document.createDocumentFragment();
    fr.append(content);
    wrapper.innerHTML = content;
    wrapper.childNodes.forEach((node) => {
      container.appendChild(node.cloneNode(true));
    });
  } else if (content.nodeType) {
    container.appendChild(content);
  } else if (content.length) {
    content.forEach((node) => {
      container.appendChild(node);
    });
  }
}
